<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>自定义错误类</title>
</head>
<body>
    
</body>
<script>
    // 这个就是自定义的错误类  继承的是JS的基础错误类
    class myErr extends Error{
        constructor(msg){  //构造器
            super(msg)   //输出super
            this.name = 'myErr'
        }
    }
    let promise = new Promise((resolve,reject)=>{
        reject(new myErr('失败啦'))
    }).catch((res)=>{
        console.log(res.message)   //接收错误是通过  message属性来获取错误的值
    })
</script>
</html>